/**
 * 
 */
package es.ibm.santillana.mdm.workflow.creacion;


import java.util.Iterator;

import com.ibm.pim.attribute.AttributeInstance;
import com.ibm.pim.catalog.Catalog;
import com.ibm.pim.catalog.CatalogManager;
import com.ibm.pim.catalog.item.Item;
import com.ibm.pim.collaboration.CollaborationItem;
import com.ibm.pim.collaboration.CollaborationStep;
import com.ibm.pim.collaboration.ItemCollaborationArea;
import com.ibm.pim.collection.PIMCollection;
import com.ibm.pim.common.ExtendedValidationErrors;
import com.ibm.pim.common.exceptions.PIMInvalidOperationException;
import com.ibm.pim.context.Context;
import com.ibm.pim.context.PIMContextFactory;
import com.ibm.pim.extensionpoints.WorkflowStepFunction;
import com.ibm.pim.extensionpoints.WorkflowStepFunctionArguments;
import com.ibm.pim.utils.Logger;

import es.ibm.santillana.mdm.common.bussinesmodel.ConfigModel;
import es.ibm.santillana.mdm.common.bussinesmodel.WorkflowManagement;
import es.ibm.santillana.mdm.common.util.ConstSantillana;
import es.ibm.santillana.mdm.common.util.SantillanaLogger;

/**
 * @author Benito
 *
 */
public class Initial implements WorkflowStepFunction {

	/**
	 * 
	 */
	public Initial() {
		// TODO Auto-generated constructor stub
	}

	/* (non-Javadoc)
	 * @see com.ibm.pim.extensionpoints.WorkflowStepFunction#in(com.ibm.pim.extensionpoints.WorkflowStepFunctionArguments)
	 */
	@Override
	public void in(WorkflowStepFunctionArguments arg0) {
		// TODO Auto-generated method stub
		
		
		Logger log = SantillanaLogger.getLogger();
		System.out.println("IN DE INITIAL DE CREACION");
		PIMCollection <CollaborationItem> collabItems = arg0.getItems();
		Iterator <CollaborationItem> it = collabItems.iterator();
		
		//EN ESTE WF NO SE PUEDE HACER CHECKOUT ASIQUE SI EL USUARIO lo hace lo sacamos del wf
		ItemCollaborationArea itmColArea = (ItemCollaborationArea) arg0.getCollaborationStep().getCollaborationArea();
		
		while (it.hasNext()) {
			CollaborationItem itmCol = it.next();
			
				
		
			itmColArea.drop(itmCol);
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
				
			
		}
	}

	/* (non-Javadoc)
	 * @see com.ibm.pim.extensionpoints.WorkflowStepFunction#out(com.ibm.pim.extensionpoints.WorkflowStepFunctionArguments)
	 */
	@Override
	public void out(WorkflowStepFunctionArguments arg0) {}

	/* (non-Javadoc)
	 * @see com.ibm.pim.extensionpoints.WorkflowStepFunction#timeout(com.ibm.pim.extensionpoints.WorkflowStepFunctionArguments)
	 */
	@Override
	public void timeout(WorkflowStepFunctionArguments arg0) {
		// TODO Auto-generated method stub

	}

}
